<?php

namespace plugin\admin\app\model;

use plugin\admin\app\model\Base;

/**
 * @property integer $id (主键)
 * @property integer $pid 商品ID
 * @property integer $target_count 开奖目标数
 * @property integer $fake_sale_count 虚拟销量
 * @property integer $sale_count 销量
 * @property integer $fake_process 虚拟进度条
 * @property integer $start_time 开始时间
 * @property integer $end_time 结束时间
 * @property integer $unfinish_prize_draw 未到达目标是否开奖
 * @property integer $auto_loop 结束后是否自动循环
 * @property string $created_time 创建时间
 */
class PrizeDrawActivity extends Base
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wa_prize_draw_activities';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';
    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    const STATUS_ACTIVE = 0;

    const STATUS_OPEN = 1;

    const STATUS_CLOSE = 2;

    const TYPE_SINGLE = 1;

    const TYPE_MULTI = 2;

    const STATUS_TEXT = [
        self::STATUS_ACTIVE => '待开奖',
        self::STATUS_OPEN => '已开奖',
        self::STATUS_CLOSE => '结束未开奖'
    ];

    const TYPE_TEXT = [
        self::TYPE_SINGLE => '单品',
        self::TYPE_MULTI => '混合'
    ];

    public static function getStatusText($status)
    {
        return self::STATUS_TEXT[$status] ?? '';
    }

    public static function getTypeText($type)
    {
        return self::TYPE_TEXT[$type] ?? '';
    }

    public static function buildTitle($activity)
    {
        return '第' . $activity['loop_count'] . '期' . $activity['name'];
    }
}
